package com.yunxun.coinmessage.dao;


import com.yunxun.coinmessage.entity.Content;
import com.yunxun.coinmessage.sqlvo.ContentVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
@Mapper
@Component
public interface ContentDao {

    @Insert("insert into content (con_article,create_time,con_addr,con_author,con_title,coin_id,exchange_id,program_id,verifycode,status) values(#{con_article},#{create_time},#{con_addr},#{con_author},#{con_title},#{coin_id},#{exchange_id},#{program_id},#{verifycode},#{status})")
    @Options(useGeneratedKeys=true, keyProperty="con_id", keyColumn="con_id")
    int addConten(Content content);
    @Insert("insert into content (con_article,create_time,con_addr,con_author,con_title,coin_id,exchange_id,program_id,verifycode,status,sort)values(#{con_article},#{create_time},#{con_addr},#{con_author},#{con_title},#{coin_id},#{exchange_id},#{program_id},#{verifycode},#{status},#{sort})")
    @Options(useGeneratedKeys=true,keyProperty="con_id", keyColumn="con_id")
    int addContenByCollector(Content content);
    @Select("select * from content where con_id=#{con_id}")
     Content queryContentById(Integer con_id);
    @Update("update content set status=#{status} where con_id=#{con_id}")
    Integer updateStatus(@Param("con_id") Integer con_id,@Param("status") Integer status);
    @Select("select count(*) from content where status!=3")
    Integer queryTotal();
    @Update("update content set coin_id=#{coin_id},exchange_id=#{exchange_id},program_id=#{program_id},con_article=#{con_article},con_addr=#{con_addr},con_author=#{con_author},con_title=#{con_title},create_time=#{create_time} where con_id=#{con_id} and status!=3")
    Integer updateContentById(Content content);
    @Select("select count(*) from content where verifycode=#{verifycode} and status!=3")
    int queryByVerifycode(String verifycode);
    @Select("select count(*) from content where con_title=#{con_title} and status!=3")
    public int queryContentByName(String con_title);
    int queryTotalByCondition(ContentVO contentVO);
    List<Content> queryByPage(ContentVO contentVO);
}
